import os
import json
import shutil 


concept_dir_files = os.listdir("./14.concept_circle")
# concept_species_dirs = [os.path.join("./14.concept_circle", x) for x in concept_dir_files]

output_dir = "./18.production"
os.makedirs(output_dir, exist_ok=True)

for file in concept_dir_files:
    out_dir = os.path.join("./18.production", file)
    os.makedirs(out_dir, exist_ok=True)
    
    # 拷贝圈图数据
    circle_source_dir = os.path.join("./14.concept_circle", file)  # Source directory
    circle_target_dir = os.path.join(out_dir, "concept")  # Target directory
    
    # Create target directory if it doesn't exist
    os.makedirs(circle_target_dir, exist_ok=True)
    
    # Copy all files from source to target
    for item in os.listdir(circle_source_dir):
        src = os.path.join(circle_source_dir, item)
        dst = os.path.join(circle_target_dir, item)
        if os.path.isdir(src):
            shutil.copytree(src, dst, dirs_exist_ok=True)
        else:
            shutil.copy2(src, dst)
            
    density_path = os.path.join("./15.density", file + "___density.json")
    
    # 拷贝密度文件
    if os.path.exists(density_path):
        shutil.copy2(density_path, os.path.join(out_dir, file + "___density.json"))
    else:
        print(f"Warning: Density file not found at {density_path}")
